package com.bauer.activiti.controller;

import com.bauer.activiti.dto.RepayApplyDTO;
import java.util.HashMap;
import java.util.Map;
import org.activiti.engine.RuntimeService;
import org.activiti.engine.TaskService;
import org.activiti.engine.runtime.Execution;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @description:
 * @author: weirui
 * @create: 2020-01-03 16:30
 **/
@RestController
@RequestMapping("/repay")
public class RepayController {

    @Autowired
    private RuntimeService runtimeService;

    @Autowired
    private TaskService taskService;

    @RequestMapping("/start")
    public void startRepay(RepayApplyDTO repayApplyDTO) {
        Map<String, Object> map = new HashMap<>();
        map.put("debitType", repayApplyDTO.getDebitType());
        runtimeService.startProcessInstanceByKey("myProcess", "24", map);
    }


    @RequestMapping("/continue")
    public void continueRepay(RepayApplyDTO repayApplyDTO) {
        Execution execution = runtimeService.createExecutionQuery().processDefinitionKey("myProcess")
            .processInstanceBusinessKey("123132").singleResult();
        runtimeService.signal(execution.getId());
    }

}
